package org.jeecg.modules.system.mapper;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.SqlParser;
import org.apache.catalina.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.system.entity.SysDepartPosition;
import org.jeecg.modules.system.entity.SysUserPosition;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @Description: 用户岗位表
 * @Author: jeecg-boot
 * @Date:   2019-08-04
 * @Version: V1.0
 */
public interface SysUserPositionMapper extends BaseMapper<SysUserPosition> {

	boolean deleteByMainId(String mainId);
	List<SysUserPosition> selectByMainId(@Param("mainId") String mainId,@Param("sqlMap") String sqlMap);
	@SqlParser(filter = true)
	List<SysUserPosition> selectServerByMainId(@Param("mainId") String mainId,@Param("tenantId") String tenantId);

	Integer selectPosition(Map map);
	@Select("select * from sys_user_position where user_id =#{userId} and del_flag='0'")
	SysUserPosition existPosition(@Param("userId")String userId);
    @Update("update sys_user_position set position_id =#{positionId} where user_id=#{userId} and del_flag='0'")
    Integer updatePosition(@Param("positionId")String str,String userId);

	List<SysDepartPosition> selectPositionId(@Param("userId") String userId);
    @Select("select user_id ,position_id from sys_user_position where depart_id=#{departId} del_flag = '0'")
	List<SysUserPosition> selectPositionIds(@Param("departId") String departId);

    void addBatch(@Param("userId") String userId,@Param("departId") String departId, @Param("sysDepartPosition") List<SysDepartPosition> sysDepartPosition);
    @Select("select * from sys_user_position where user_id =#{userId} AND del_flag ='0'")
	List<SysUserPosition> selectDepartPosition(@Param("userId") String userId);


    @Select("select count(0) from sys_user_position where user_id =#{userId} AND depart_position_id = #{departPositionId} and del_flag = '0'")
	Integer selectByDepartPositionId(@Param("departPositionId") String receiveAttr,@Param("userId") String userId);

	void editBatch(@Param("userId") String userId,@Param("departId") String departId);

	List<String> queryPositionId(@Param("userId") String userId,@Param("departId") String departId);
}
